home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 October / enter-2005-10.iso / files / jedit42install.exe / {app} / macros / Editing / Go_to_Column.bsh < prev    next >
Encoding:
Text File  |  2004-08-29  |  1.1 KB  |  52 lines

  1. /*
  2.  * Go_to_Column.bsh - a BeanShell macro for the jEdit text
  3.  * editor - Prompts the user for a column position on the
  4.  * current line, then moves the caret there.
  5.  *
  6.  * Copyright (C) 2003 Ollie Rutherfurd <oliver@rutherfurd.net>
  7.  *
  8.  * $Id: Go_to_Column.bsh,v 1.1 2004/03/19 15:57:59 spestov Exp $
  9.  */
  10. goToColumn()
  11. {
  12.     line = textArea.getCaretLine();
  13.     len = textArea.getLineLength(line) + 1;
  14.     while(true)
  15.     {
  16.         col = Macros.input(view, "Column (between 1 and " + len + "):");
  17.         if(col == null)
  18.             return;
  19.         else
  20.         {
  21.             try
  22.             {
  23.                 col = Integer.parseInt(col);
  24.                 if(col >= 1 && col <= len)
  25.                 {
  26.                     lineStartOffset = textArea.getLineStartOffset(line);
  27.                     textArea.setCaretPosition(lineStartOffset + (col-1));
  28.                     textArea.requestFocus();
  29.                     return;
  30.                 }
  31.             }catch(NumberFormatException e){
  32.             }
  33.         }
  34.     }
  35. }
  36.  
  37. goToColumn();
  38.  
  39. /*
  40.     Macro index data (in DocBook format)
  41.  
  42. <listitem>
  43.     <para><filename>Go_to_Column.bsh</filename></para>
  44.     <abstract><para>
  45.         Prompts the user for a column position on the 
  46.         current line, then moves the caret there.
  47.     </para></abstract>
  48. </listitem>
  49.  
  50. */
  51.  
  52.